/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package simplemetrosystem.model.Command.EditCommand;

import simplemetrosystem.control.ElementManager;
import simplemetrosystem.model.Command.Command;
import simplemetrosystem.model.Element.MetroEdge;
import simplemetrosystem.model.Element.MetroLine;

/**
 *
 * @author Eric Qian
 */
public class EditEdgeCommand implements Command {

    /**
     * 
     * @param edge
     * @param line
     * @param serialNumber
     * @param distance
     * @param time
     */
    public EditEdgeCommand(MetroEdge edge, MetroLine line, int serialNumber, double distance, double time) {
        this.edge = edge;
        this.line = line;
        this.serialNumber = serialNumber;
        this.distance = distance;
        this.time = time;
        tempLine = edge.getLine();
        tempSerialNumber = edge.getSerialNumber();
        tempDistance = edge.getDistance();
        tempTime = edge.getTime();
    }

    public void execute() {
        ElementManager.getInstance().editEdge(
                edge, line, serialNumber, distance, time);
    }

    public void undo() {
        ElementManager.getInstance().editEdge(
                edge, tempLine, tempSerialNumber, tempDistance, tempTime);
    }
    private MetroEdge edge;
    private MetroLine line;
    private int serialNumber;
    private double distance;
    private double time;
    private MetroLine tempLine;
    private int tempSerialNumber;
    private double tempDistance;
    private double tempTime;
}
